from django.db import models
from rest_framework import serializers


# Create your models here.
class SysUser(models.Model):
    id = models.AutoField(primary_key=True)
    username = models.CharField(max_length=20, unique=True, verbose_name='用户名(登录用)')
    nickname = models.CharField(max_length=20, verbose_name='昵称(展示用)')
    password = models.CharField(max_length=50, verbose_name='密码')
    avatar = models.CharField(max_length=500, null=True, verbose_name='头像')
    login_time = models.DateTimeField(auto_now_add=True, null=True, verbose_name='最后登录时间')

    class Meta:
        db_table = "sys_user"


class SysUserSerializer(serializers.ModelSerializer):
    class Meta:
        model = SysUser
        fields = ['id', 'username', 'avatar']


class SysUserFullSerializer(serializers.ModelSerializer):
    class Meta:
        model = SysUser
        fields = '__all__'  # 返回所有字段